<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
	<meta charset="UTF-8">
	<title>修改登录密码</title>
	<meta name="description" content="">
	<meta name="keywords" content="">
	<meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
	<meta name="format-detection" content="telephone=no,email=no,adress=no" />
	<meta name="apple-mobile-web-app-capable" content="yes" />  
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<link rel="stylesheet" href="{THEME_PATH}styles/swiper.min.css">
	<link rel="stylesheet" href="{THEME_PATH}styles/reset.css">
	<link rel="stylesheet" href="{THEME_PATH}styles/common.css">
	<link rel="stylesheet" href="{THEME_PATH}styles/style.css">	
</head>
<body>
	<!-- S header -->
	<header>
		<a href="/index.php?m=user&c=home&a=upd_password" class="headerL iconfont">&#xe69f;</a>
		<h1>修改登录密码</h1>
	</header>
	<!-- E header -->
	<dl class="sendTo">
		<dt id="sms_code">发送验证码到</dt>
		<dd class="number"><?php echo $user_info['username'];?></dd>
	</dl>

	<ul class="change_num_box">
		<li class="flex">
			<label class="label">验证码</label>
			<div class="flex-1 input_box"><input type="text" placeholder="请输入验证码" name="msg_code"></div>
			<a href="javascript:;" class="get-code">获取验证码</a>
		</li>
		<li class="flex">
			<label class="label">新密码</label>
			<div class="flex-1 input_box"><input type="password" placeholder="请输入新密码" name="password"></div>
		</li>
	</ul>

	<a href="javascript:;" class="btn">提交</a>
</body>
<script src="{THEME_PATH}js/jquery-1.8.3.min.js"></script>
<script src="{THEME_PATH}js/swiper.min.js"></script>
<script src="/statics/js/layer/layer.js"></script>
<script>
	$('.get-code').click(function(){
		var username = <?php echo $user_info['username']; ?>;
		$.ajax({
			url: "{U('User/Public/send_code')}&token={$_SESSION[send_code_time]}&type=forget&mobile="+username,
			timeout: 5000,
			cache: false,
			type: "get",
			async : false,
			dataType: "json",
			success: function (d){
				if(d.status==1){
				$('#sms_code').text('已发送验证码到');
				downtime(120);
				}
				layer.msg(d.info);
				// tips(d.info);
			}
    	});
	})

	$('.btn').click(function(){
		console.log(111);
		var username = <?php echo $user_info['username']; ?>;
		var msg_code =$("input[name='msg_code']").val();
		var password = $("input[name='password']").val();
		if(!msg_code){
			layer.msg('请输入短信验证码');
			return;
		}
		var password_length = password.length;
		if(!password || password_length <6 || password_length > 16){
			layer.msg('请输入6-16位的登录密码 ');
			return;
		}
		$.ajax({
			url:'/index.php?m=user&c=public&a=forget_password',
			data:{
				username:username,
				sms_code:msg_code,
				password:password,
			},
			type:'post',
			dataType:'json',
			success:function(data){
				if(data.status ==0){
					layer.msg(data.info);
				}else{
					layer.msg(data.info);
					setTimeout(function(){
							location.reload();
						},1000);
					// location.href = "/index.php?m=user&c=public&a=login";
					
					return;
				}
			}

		});

	})

	
	/**
		* 验证码倒计时
		* time 倒计时时间：秒
	**/
	function downtime(time){
		//循环调用
		if(time == '0'){
			$('.send_code').text('发送验证码');
		}else{
			time --;
			$('.send_code').text('重新发送('+time+')');
			setTimeout(function() {
			downtime(time);
			},1000);
		}
	}
</script>
</html>